<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <include file="./Public/Admin/header.html" />
    <style>
        .form-horizontal .control-group {
            margin-bottom: 10px;
        }
        .input-medium {
            width: 480px;
        }
        input {
            width: 450px;
        }
    </style>

</head>
<body>
<div id="main">
    <div class="container-fluid">

        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div class="box-title">
                        <div class="span10">
                            <?php if($_GET['action'] == 'add'):?>
                            <h3><i class="icon-edit"></i>课程回顾添加</h3>
                            <?php else:?>
                            <h3><i class="icon-edit"></i>课程回顾编辑</h3>
                            <?php endif;?>
                        </div>
                        <div class="span2"><a class="btn" href="javascript:void(0)" onclick="javascript:window.history.go(-1)">返回</a></div>
                    </div>

                    <div class="box-content">
                        <form action="{:U('edit')}" method="post" class="form-horizontal form-validate">

                            <div class="control-group">
                                <label for="name" class="control-label">文章名称：</label>
                                <div class="controls">
                                    <input type="text" name="name" id="name" class="input-medium" value="<?php echo $info['name']; ?>" data-rule-required="true" /><span class="maroon">*</span>
                                </div>
                            </div>

                            <div class="control-group">
                                <label for="value" class="control-label">文章内容：</label>
                                <div class="controls">
                                    <textarea name="value" style="width:80%;" id="value" class="input-medium" ><?php echo $info['value'];?></textarea>
                                </div>
                            </div>

                            <div class="form-actions">
                                <input type="hidden" name="id" id="id" value="<?php echo $info['id']; ?>"/>
                                <input type="hidden" name="action" id="action" value="<?php echo $_GET['action']?>"/>
                                <button type="button" class="btn btn-primary" id="btnsave">保存</button>

                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<script type="text/javascript">
    $("#btnsave").click(function(){
        var share_img = $("#images").val();
        if(share_img == ''){
            G.ui.tips.err('请上传课程图片');
            return false;
        }
        $("#btnsave").submit();
    });
</script>
<script type="text/javascript" charset="utf-8" src="__APP__/Public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__APP__/Public/ueditor/ueditor.all.js"></script>

<script type="text/javascript">
    //设置编辑器参数
    var param="user_name=<?php echo $sysuser['user_name']?>";
    var options = {
        initialFrameWidth:700,
        initialFrameHeight: 200,
        imageUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL+"php/imageUp.php?"+param,
        fileUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL+"php/fileUp.php?"+param,
        imageManagerUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL + "php/imageManager.php?"+param,
        toolbars:[
            [ 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist',  '|',

                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'indent',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                'link', 'unlink', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'insertimage', 'emotion',  'horizontal','|','help']
        ]
    };
    var ue = UE.getEditor('kjieshao', options);
    var ue = UE.getEditor('value', options);
</script>
<script type="text/plain" id="upload_ue" style="display: none;"></script>
<script type="text/javascript">

var typeid='';
//重新实例化一个编辑器，防止在上面的editor编辑器中显示上传的图片或者文件
var _editor = UE.getEditor('upload_ue',options);
_editor.ready(function () {
    //设置编辑器不可用
    _editor.setDisabled();
    //隐藏编辑器，因为不会用到这个编辑器实例，所以要隐藏
    _editor.hide();
    //侦听图片上传
    _editor.addListener('beforeInsertImage', function (t, arg) {
        //将地址赋值给相应的input,只去第一张图片的路径
        imgurl=arg[0].src;
        $("#images").val(imgurl);
        $("#show_img").attr("src",imgurl);
    })

    //侦听文件上传，取上传文件列表中第一个上传的文件的路径
    _editor.addListener('afterUpfile', function (t, arg) {
        $("#file").attr("value", _editor.options.filePath + arg[0].url);
    })
});
//弹出图片上传的对话框
function upImage(type) {
    typeid=type
    var myImage = _editor.getDialog("insertimage");
    myImage.open();
}
//弹出文件上传的对话框
function upFiles() {
    var myFiles = _editor.getDialog("attachment");
    myFiles.open();
}
</script>
</body>
</html>
